import component from "../../../common/component";
import {Button, Col, Input,Row} from "antd";
import EditModal from "./edit";
import ApproveBtn from "@components/ApproveBtn"

class bormanage extends component {

    //搜索栏  搜索栏不可指定搜索属性搜索
    getSearchRow(): null {
        return <Input.Group>
            <Row gutter={8}>
                <Col span={6}>
                    <Input onChange={this.handleChange} allowClear placeholder="设备名称" onPressEnter={this.reload}
                           name={'name'}/>
                </Col>
                <Col span={3}>
                    <Button type={'primary'} onClick={this.reload}>搜索</Button>
                </Col>
            </Row>
        </Input.Group>;
    }

    //主体部分页眉
    getColumns(): null {
        return [
            {
                title: '设备编号',
                dataIndex: 'equCode',
                key: 'equCode',
                width: 150,
              
            },
            {
                title: '设备名称',
                dataIndex: 'equName',
                key: 'equName',
                width: 150,
            },
             //借用人姓名
             {
                title: '借用人姓名',
                dataIndex: 'userName',
                key: 'userName',
                width: 150,         
            },
            //借用人学号
            {
                title: '借用人学号',
                dataIndex: 'userNumber',
                key: 'userNumber',
                width: 150,         
            },
            {
                title: '预计归还时间',
                dataIndex: 'etime',
                key: 'etime',
                width: 150,  
                sorter: (a, b) => {
                    // 将日期转成毫秒
                      const t1 = new Date(a.etime).getTime();
                      const t2 = new Date(b.etime).getTime();
                      return t1- t2
                    },
                    sortDirections: ['descend', 'ascend'],
                    defaultSortOrder: 'descend'
                
            },
            {
                title: '借用理由',
                dataIndex: 'text',
                key: 'text',
                width: 150,   
            },
            {
                title: '操作',
                dataIndex: 'operation',
                fixed: 'right',
                width: 100,
                render: (_, record) => {
                    return <ApproveBtn record={record} edit={this.edit}/>
                },
            }
        ];
    }


    getEditModal(): null {
        return <EditModal {...this.state.editParam} cancelModal={this.cancelModal} reload={this.reload}
                          baseUir={this.state.baseUri}/>
    }
}

export default bormanage;